//
//  HMSinaBaseNavigationController.swift
//  ZJCSina
//
//  Created by 朱建超 on 16/11/13.
//  Copyright © 2016年 itHeiMa. All rights reserved.
//

import UIKit

class HMSinaBaseNavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

    }
    
    //重写push方法
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        
        let count = childViewControllers.count
        
        if count > 0 {
            
            //同一操作
            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "返回", imageName: "navigationbar_back_withtext", target: self, action: #selector(back))
            
            //隐藏底部的tabbarItem
            viewController.hidesBottomBarWhenPushed = true
            
        }
        
        super.pushViewController(viewController, animated: animated)
        
    }
    
    @objc private func back() {
        
        popViewController(animated: true)
        
    }

}
